package com.ty.game.config;

import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author: Troy.Chen(失足程序员, 15388152619)
 * @version: 2021-07-29 16:56
 **/
@Configuration
@AutoConfigureAfter(DataSourceConfig.class)
public class MyBatisConfig {

    @Value("${mybatis.model.pack}")
    private String Entity_Pack_Name;
    @Value("${mybatis.dao.pack}")
    private String Dao_Pack_Name = "com.ty.game.dao";

    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer() throws Exception {
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        String basePackage = "com.gitee.sunchenbin.mybatis.actable.dao.*";// + Entity_Pack_Name + ";" + Dao_Pack_Name;
        mapperScannerConfigurer.setBasePackage(basePackage);
        mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
        return mapperScannerConfigurer;
    }

}

